package org.mech.sefer.entity.bible.model;

import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.mech.sefer.entity.model.AbstractEntity;

/**
 * <p>
 * The Book model represent book in bible.
 * </p>
 * <p>
 * Date: 4.5.2012 14:21:51
 * </p>
 *
 * @author martin.krajc
 */
@Entity
@Table(name = "T_BOOKS")
public class Book extends AbstractEntity {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -8284653904035200973L;

	/** The id. */
	@Id
	@SequenceGenerator(name = "T_BOOKS_SEQ", sequenceName = "T_BOOKS_SEQ", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "T_BOOKS_SEQ")
	@Column(name = "ID", nullable = false, updatable = false)
	private Long id;

	/** The semantic book reference for this book. */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "S_ID")
	private SemanticBook semantic;

	/** The name of bible. */
	@Column(name = "NAME")
	private String name;

	/** The abbreviation for bible. */
	@Column(name = "ABBRV")
	private String abbreviation;

	/** The position of booki in its bible. */
	@Column(name = "POSITION", length=3)
	private Integer positionInBible;

	/** The chapter count of this book. */
	@Column(name = "CHAPTER_COUNT",length=3)
	private Integer chapterCount;

	/** The bible reference. */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "BIBLE_ID", nullable = false, columnDefinition="number" )
	private Bible bible;

	/** The verses in book. */
	@OneToMany(mappedBy = "book", cascade = javax.persistence.CascadeType.ALL, fetch = FetchType.LAZY)
	private Collection<Verse> verses;

	/**
	 * {@inheritDoc}
	 */
	public Long getId() {
		return id;
	}

	
	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Gets the semantic reference.
	 *
	 * @return the semantic reference
	 */
	public SemanticBook getSemantic() {
		return semantic;
	}

	/**
	 * Sets the semantic reference
	 *
	 * @param semantic the new semantic reference
	 */
	public void setSemantic(SemanticBook semantic) {
		this.semantic = semantic;
	}

	/**
	 * Gets the name of book
	 *
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the name of book
	 *
	 * @param name the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the abbreviation.
	 *
	 * @return the abbreviation
	 */
	public String getAbbreviation() {
		return abbreviation;
	}

	/**
	 * Sets the abbreviation.
	 *
	 * @param abbreviation the new abbreviation
	 */
	public void setAbbreviation(String abbreviation) {
		this.abbreviation = abbreviation;
	}

	/**
	 * Gets the position in bible.
	 *
	 * @return the position in bible
	 */
	public Integer getPositionInBible() {
		return positionInBible;
	}

	/**
	 * Sets the position in bible.
	 *
	 * @param positionInBible the new position in bible
	 */
	public void setPositionInBible(Integer positionInBible) {
		this.positionInBible = positionInBible;
	}

	/**
	 * Gets the chapter count.
	 *
	 * @return the chapter count
	 */
	public Integer getChapterCount() {
		return chapterCount;
	}

	/**
	 * Sets the chapter count.
	 *
	 * @param chapterCount the new chapter count
	 */
	public void setChapterCount(Integer chapterCount) {
		this.chapterCount = chapterCount;
	}

	/**
	 * Gets the bible.
	 *
	 * @return the bible
	 */
	public Bible getBible() {
		return bible;
	}

	/**
	 * Sets the bible.
	 *
	 * @param bible the new bible
	 */
	public void setBible(Bible bible) {
		this.bible = bible;
	}

	/**
	 * Gets the verses.
	 *
	 * @return the verses
	 */
	public Collection<Verse> getVerses() {
		return verses;
	}

	/**
	 * Sets the verses.
	 *
	 * @param verses the new verses
	 */
	public void setVerses(Collection<Verse> verses) {
		this.verses = verses;
	}

}
